/*	TGDefaultsManager.h
 *	Part of ThinkGeek LED Clock
 *	http://tmorgan.shutupgeorge.com/thinkgeek/
 *
 * Copyright (c)2003-2006 Tim Morgan. All rights reserved. Please visit
 * http://tmorgan.shutupgeorge.com/other/license.html for more information about
 * your rights and responsibilities regarding this source code.
 */

#import <Cocoa/Cocoa.h>
#import <ScreenSaver/ScreenSaverDefaults.h>

#import "TGErrorManager.h"

/**
 * Number representing the preferences format this program expects. Each time
 * the preferences format is changed such that it is backwards-incompatable with
 * the previous format, this number is incremented.
 */
const NSString *TGLatestPreferencesVersion;

/**
 * Singleton class that allows access to the program's defaults. This class is
 * instantiated by the nib code and can be accessed through
 * {@link defaultsManager}. It acts as both a model in the Cocoa-bindings setup
 * of the preferences window and also as an interface to the
 * <code>ScreenSaverDefaults</code> object that is managing the defaults.
 *
 * @author Tim Morgan
 */

@interface TGDefaultsManager : NSObject {
	@private ScreenSaverDefaults *defaults;
}

/**
 * Returns the background color of the clock as specified in the preferences.
 *
 * @return The clock's background color
 */

- (NSColor *) backgroundColor;

/**
 * Sets the background color.
 *
 * @param newColor the new background color
 */

- (void) setBackgroundColor:(NSColor *)newColor;

/**
 * Returns the path to the background image as specified in the preferences.
 *
 * @return The path to the background image file
 */

- (NSString *) backgroundImageFilePath;

/**
 * Sets the background image file path. This setting will be reflected in the
 * preferences.
 *
 * @param newPath the new background image file path
 */

- (void) setBackgroundImageFilePath:(NSString *)newPath;

/**
 * Validates that the given file path is a path to an actual, existing file.
 *
 * @param path a reference the file path to validate
 * @param error a reference to an NSError object, non-null if the file path is
 *              invalid
 * @return True if the path is valid; false if it is not
 */

- (BOOL) validateBackgroundImageFilePath:(NSString **)path error:(NSError **)outError;

/**
 * Returns the background style as specified in the preferences. The style is a
 * string constant.
 *
 * @return The clock's background style
 */

- (NSString *) backgroundStyle;

/**
 * Sets the background style. This setting will be reflected in the preferences.
 *
 * @param newStyle the new background style
 */

- (void) setBackgroundStyle:(NSString *)newStyle;

/**
 * Validates that the given background style is a known string constant. If it
 * isn't, the <code>NSError</code> reference will contain an error of type -100.
 *
 * @param style a background style
 * @param error a reference to an NSError object, non-null if the style is
 *              invalid
 * @return True if the style is valid; false if it is not
 */

- (BOOL) validateBackgroundStyle:(NSString **)style error:(NSError **)outError;

/**
 * Returns a boolean indicating if updates are checked automatically, as
 * specified in the preferences.
 *
 * @return True if the program periodically checks for updates; false otherwise
 */

- (BOOL) checkUpdatesAutomatically;

/**
 * Sets whether or not the program periodically checks for updates. This setting
 * will be reflected in the preferences.
 *
 * @param willCheck true if the application will periodically check for updates
 */

- (void) setCheckUpdatesAutomatically:(BOOL)willCheck;

/**
 * Returns the size of the clock as an integer from 2 to 10, as specified in the
 * preferences.
 *
 * @return The clock's size as an integer
 */

- (int) clockSize;

/**
 * Sets the clock size. This setting will be reflected in the preferences.
 *
 * @param newSize the new clock size
 */

- (void) setClockSize:(int)newSize;

/**
 * Validates that the clock size is between 2 and 10. If it isn't, the clock
 * size is snapped down to 10 or up to 2, whichever is closer.
 *
 * @param size a reference to a clock size (value may be changed by this method)
 * @param error a reference to an NSError object (unused)
 * @return True unconditionally, as clock sizes are always made valid
 */

- (BOOL) validateClockSize:(int *)size error:(NSError **)outError;

/**
 * Returns the clock's theme as specified in the preferences. The theme is a
 * string constant.
 *
 * @return The clock's theme
 */

- (NSString *) clockTheme;

/**
 * Sets the clock's theme. This setting will be reflected in the preferences.
 *
 * @param newTheme the new clock theme
 */

- (void) setClockTheme:(NSString *)newTheme;

/**
 * Validates that the given clock theme is a known string constant. If it isn't,
 * the <code>NSError</code> reference will contain an error of type -101.
 *
 * @param theme a clock theme
 * @param error a reference to an NSError object, non-null if the theme is
 *              invalid
 * @return True if the theme is valid; false if it is not
 */

- (BOOL) validateClockTheme:(NSString **)theme error:(NSError **)outError;

/**
 * Returns a boolean indicating if the time is to be displayed in the 24-hour
 * format. Time is otherwise displayed in a 12-hour format.
 *
 * @return True if time is displayed in a 24-hour format; false if time is
 *         displayed in a 12-hour format
 */

- (BOOL) timeFormat24Hour;

/**
 * Sets whether or not time is displayed in the 24-hour format. This setting
 * will be reflected in the preferences.
 *
 * @param is24Hr true if time will be displayed in the 24-hour format
 */

- (void) setTimeFormat24Hour:(BOOL)is24Hr;

@end
